/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 * No deletion without permission, or be held responsible to law.
 * @author Cheng
 */
import { defHttp } from '/@/utils/http/axios';
import { useGlobSetting } from '/@/hooks/setting';
import { BasicModel, Page } from '/@/api/model/baseModel';
import axios from 'axios';

const { adminPath,urlPrefix } = useGlobSetting();

export interface InDeviceManagement extends BasicModel<InDeviceManagement> {
  equipmentName?: string; // 设备名称
  equipmentCode?: string; // 设备编码/二次码信息
  equipmentTypeId?: string; // 设备类型id
  equipmentType?: string; // 设备类型
  hostId?: string; // 所属主机(用传装置编码) /有主机  无主机
  enterpriseId?: string; // 企业id
  enterpriseName?: string; // 企业名称
  buildId?: number; // 安装建筑id
  buildName?: string; // 安装建筑名称
  regionId?: number; // 区域Id
  regionName?: string; // 区域名称
  floorNum?: string; // 楼层Id
  intellect?: string; // 是否智能
  factory?: string; // 设备厂家
  longitude?: string; // 经度
  latitude?: string; // 纬度
  address?: string; // 详细地址
  realStatus?: string; // 当前设备实时状态
  drill?: string; // 演练标识
  imei?: string; // IMEI
  district?: string; // 区域
  createTime?: string; // 创建时间
  updateTime?: string; // 更新时间
  deleted?: string; // 删除标识
  image?: string; // 示例图
  partition?: string; // 防火分区 
  build?: string; // 建筑
  floorId?: string; // 楼层id
  regionId1?: string; // 区域id
  fireHostId?: string; // 消防主机id
  sensorId?: string; // 传感器id
  content?: string; // 内容
  reportTime?: string; // 报告时间
  sensorStatus?: string; // 传感器状态
  addTime?: string; // 新增时间
  data?:object; // 设备数据
  file?:string; // 文件
}


export const inDeviceManagementList = (params?: InDeviceManagement | any) =>
  defHttp.get<InDeviceManagement>({ url: adminPath + '/device/management/inDeviceManagement/list', params });

export const inDeviceManagementListData = (params?: InDeviceManagement | any) =>
  defHttp.post<Page<InDeviceManagement>>({ url: adminPath + '/device/management/inDeviceManagement/listData', params });

export const inDeviceManagementForm = (params?: InDeviceManagement | any) =>
  defHttp.get<InDeviceManagement>({ url: adminPath + '/device/management/inDeviceManagement/form', params });

export const inDeviceManagementSave = (params?: any, data?: InDeviceManagement | any) =>
  defHttp.postJson<InDeviceManagement>({ url: adminPath + '/device/management/inDeviceManagement/save', params, data });

export const inDeviceManagementDelete = (params?: InDeviceManagement | any) =>
  defHttp.get<InDeviceManagement>({ url: adminPath + '/device/management/inDeviceManagement/delete', params });

export const inDeviceSenor = (params) =>
  defHttp.postJson<InDeviceManagement>({ url: adminPath + '/device/management/inDeviceManagement/getDetails', params });



export const uploadDevice = (data) => {
  return axios.post(urlPrefix+adminPath + '/device/management/inDeviceManagement/uploadDevice', data)
    .then(response => response.data)
    .catch(error => {
      console.error('上传设备时发生错误:', error);
      throw error;
    });
};

export const deleteByList = (params) => {
  return axios.post(urlPrefix+adminPath + '/device/management/inDeviceManagement/deleteByList', params)
    .then(response => response.data)
    .catch(error => {
      console.error('删除设备时发生错误:', error);
      throw error;
    });
};


export const updateDevice = (params?: any, data?: InDeviceManagement | any) =>
  defHttp.postJson<InDeviceManagement>({ url: adminPath + '/device/management/inDeviceManagement/updateDevice', params,data });
